﻿@namespace Aspire.Dashboard.Components
@using System.Collections.Immutable
@using Aspire.Dashboard.Model
@inherits FluentComponentBase

@{
    var additionalButtonAttributes = new Dictionary<string, object>(AdditionalAttributes ?? ImmutableDictionary<string, object>.Empty)
    {
        { "aria-haspopup", "true" },
        { "aria-expanded", _visible },
        { "onkeydown", (KeyboardEventArgs args) => OnKeyDown(args) }
    };
}

<FluentButton Id="@MenuButtonId" Title="@Title" Appearance="@ButtonAppearance" IconStart="@IconStart" @onclick="ToggleMenu" Disabled="@_disabled" AdditionalAttributes="@additionalButtonAttributes" Class="@ButtonClass">
    @if (string.IsNullOrWhiteSpace(Text))
    {
        <FluentIcon Value="@_icon" Color="@IconColor" />
    }
    else
    {
        @Text

        @if (!HideIcon)
        {
            <FluentIcon Value="@_icon" Color="@IconColor" Slot="end" />
        }
    }
</FluentButton>

<AspireMenu Anchor="@MenuButtonId" @bind-Open="@_visible" Items="_items" />
